package com.fingard.dsp.bank.reqrespobj.balancecheckconfirm;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RequestBase;
import com.fingard.dsp.bank.reqrespobj.balancecheckconfirm.detail.ReqBalCheckConfirmDetail;
import com.fingard.xml.XmlTextReader;

/**
 * Created by F on 2017/6/5.
 */
public class ReqBalCheckConfirmQry extends RequestBase {
    public boolean isBatch = false;//是否为批量余额查询
    public int detailCount = -1;

    private XmlTextReader xmlReader;
    public ReqBalCheckConfirmQry(XmlTextReader p_xmlReader, ReqRespHeader p_header) throws Exception{
        reqHeader = p_header;
        xmlReader = p_xmlReader;
        detailCount = xmlReader.countElement(PATH_Detail);
        if(detailCount > 0){
            isBatch = true;
        }
        else{
            isBatch = false;
            detailCount = 1;
        }
    }

    private int readCount = 0;
    public ReqBalCheckConfirmDetail readedDetail;
    public boolean readRecord() throws Exception{
        readedDetail = null;
        int tmpCount = readCount++;
        if(isBatch){
            if(xmlReader.read(PATH_Detail)){//  /ATSYH/TransReq/TransParam/DetailRecord
                readedDetail = new ReqBalCheckConfirmDetail(xmlReader.readedXElement);
                return true;
            }
            else{
                return false;
            }
        }
        else{
            if(tmpCount>0){//已经读过了
                return false;
            }
            else{
                if(xmlReader.read("/ATSYH/TransReq/TransParam")){
                    readedDetail = new ReqBalCheckConfirmDetail(xmlReader.readedXElement);
                    return true;
                }
                else{
                    return false;
                }
            }
        }
    }
}
